package com.ruoyi.common.utils;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;

public class EmptyAsNullDeserializer extends JsonDeserializer<String> {
    public EmptyAsNullDeserializer() {
    }

    public String deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
        JsonNode node = (JsonNode)jsonParser.readValueAsTree();
        return node.asText().isEmpty() ? null : node.asText();
    }
}